< previous page page_563 next page >

Page 563
        strMsg = strMsg & " (in " & objErrColl.Source & ")"
        '
        udtErrDialog.HelpFile = objErrColl.HelpFile
        udtErrDialog.HelpID = objErrColl.HelpContext
    End If
    '
    errMsg = strMsg
    '
End Function
The main job of the errMsg routine is to build a complete error message for display to the user. In order to do this, errMsg needs to know if the object that was passed was a single VBA Err object or the DAO Errors collection. That is why the errType parameter is included in the call. Also note that the errMsg method has been declared as a Public method. You can call this method from your Visual Basic 5 programs, too. That way, even if you don't want to perform all of the error-handing operations, you can use errMsg to get an improved error message for your use.
Coding the frmErrDialog Form
The last main piece of the errHandler class is a custom dialog box to display the error message and get input from the user. Often, you want to do more than just display the message and let the user press ''OK." You may ask them to retry the same process, or ask if they want to ignore the error and continue. This dialog box not only displays the message and gives you an opportunity to get a response from the user, it also allows you to provide an optional "Help" button to give the user greater support in discovering how to resolve the error.
Note.gif
Creating Help files for your Visual Basic project is covered in Appendix B of this book.

With the prjErrHandler project still open, add a form to the project. Use Table 14.4 and Figure 14.16 as guides in laying out the form.
Table 14.4. Control table for the frmErrDialog form.
ControlPropertySetting
VB.FormNamefrmErrDialog
BorderStyle3 'Fixed Dialog
Caption"Error Report"

continues

 
< previous page page_563 next page >

If you like this book, buy it!